package sixlevel.letcode.arrays;

/**
 * @author: Lee
 * @Date: 2019/5/3 0003 23:14
 * @Description:
 */
public class ArrayDelete {
    public static void main(String[] args) {
        int[] a = new int[]{3, 2, 2, 3};
        int b = 3;
        System.out.println(removeElement(a, b));
    }

    public static int removeElement(int[] nums, int val) {
        int index = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] != val) {
                nums[index] = nums[i];
                index++;
            }
        }
        return index;
    }
}
